package com.example.my_isc_nirscan.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import androidx.appcompat.app.AppCompatActivity;
import com.example.my_isc_nirscan.R;
import com.example.my_isc_nirscan.utils.HttpUtils;

/**
 * 测试一下请求接口
 */
public class HttpActivity extends AppCompatActivity {
    private Button sendButton;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

//        sendButton = findViewById(R.id.sendButton);

        sendButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String jsonData = "{\"key\":\"value\"}";
                HttpUtils.getInstance().post("http://your-api-url.com", jsonData, new HttpUtils.HttpCallback() {
                    @Override
                    public void onSuccess(String response) {
                        // 处理成功响应
                    }

                    @Override
                    public void onFailure(Exception e) {
                        // 处理失败情况
                        e.printStackTrace();
                    }
                });
            }
        });
    }
}
